package piconode.ext;

import piconode.core.operator.ActivationFunctionWithDerivative;

/*
 * Created on 6 janv. 2005
 * bredeche(at)lri(point)fr
 * 
 */

public class ActivationFunction_Heaviside extends ActivationFunctionWithDerivative {

	/*
	 * Data
	 */

	protected static double _thresholdDefaultValue = 0.5; // default parameter
	// value
	protected double _thresholdValue;

	/*
	 * Constructor(s)
	 */

	public ActivationFunction_Heaviside() {
		this._thresholdValue = ActivationFunction_Heaviside.getDefaultThresholdValue();
	}

	public ActivationFunction_Heaviside(double __value) {
		this._thresholdValue = __value;
	}

	/*
	 * Methods
	 */

	static protected double getDefaultThresholdValue() {
		return (_thresholdDefaultValue);
	}

	@Override
	public double applyFunction(double __value) // f(x) = 1 if x > threshold,
	// f(x) = O otherwise
	{
		if (__value >= this._thresholdValue)
			return (1);
		else
			return (0);
	}

	/**
	 * note: no derived function for this function -- learning is impossible
	 * with the threshold function.
	 */
	@Override
	public double applyDerivativeFunction(double __value) // f'(x) = undefined
	{
		System.out.println("ThresholdActivationFunction::applyDerivativeOfActivationFunction(-) - does not exists!");
		System.exit(-1);
		return (-1);
	}

}
